$NG.AllReady(function (page, { useDataIndexChange, useValuesChange, useUpdateRows, useClick, useBeforeClick }) {
    const mstform = $NG.getCmpApi("p_form_fact_outout_value_m");
    const grid = $NG.getCmpApi("p_form_fact_outout_value_d");


    {//初始化逻辑BEGIN
        if (mstform) {
            console.log(mstform.name + ' is ready');
            PCFilter();
        } else {
            console.error('mstform is not available');
        };
    }//初始化逻辑END

    // 重写评分提交
    window.$PJ.submit = function (datas) {
        try {
            datas.forEach(item => {
                let key = ''
                switch (item.productId) {
                    case '交付及时性':
                        key = 'u_jfjs_score'
                        break
                    case '服务响应':
                        key = 'u_fwxy_score'
                        break
                    case '交付质量':
                        key = 'u_jfzl_score'
                        break
                    case '资源投入':
                        key = "u_zytr_score"
                        break
                }
                mstform.getItem(key).setValue((Number(item.score) || 0))
            })
            window.$PJ.onHiddenPj()
        } catch (e) {
            console.log(`发生异常`, e);
        }
    }
    useBeforeClick(() => {
        const key = ["u_jfjs_score", "u_fwxy_score", "u_jfzl_score", "u_zytr_score",]
        let lock = true
        key.forEach(item => {
            if (!mstform.getItem(item).getValue()) {
                lock = false
            }
        })
        if (!lock) {
            window.$PJ.onShowPj()
        }
        return lock
    }, "save")

    if (page.oType == "add") {
        var pc = mstform.getItem("phid_pc")
        var dt = mstform.getItem("bill_dt")
        var u_plan_type = mstform.getItem("u_plan_type")

        mstform.getItem("u_total_sum").setValue('0')
        mstform.getItem("u_kg_sum").setValue('0')

        console.log('123123');
        if (pc.getValue() > '0') {
            Czqd(pc.getValue())
            PCFilter();
        }
        getTjzq(dt.getValue())

        u_plan_type.setValue('01')
    }
    if (page.oType == "add" || page.oType == "edit") {
        { //添加按钮
            // $NG.getCmpApi('toolbar_p_form_fact_outout_value_d').insert({
            //     id: "czadd",
            //     text: "引用深化设计清单内容",
            //     iconCls: "icon-New"
            // });

            // $NG.getCmpApi('toolbar_p_form_fact_outout_value_d').insert({
            //     id: "czsbqd",
            //     text: "引用设备清单内容",
            //     iconCls: "icon-New"
            // });
        }
    }
    page.oType == 'add' && getPtInfoByPhid()
    function getPtInfoByPhid() {
        if (mstform.getItem("phid_pc").getValue()) {
            $NG.execServer(
                "getPtInfoByPhid",
                { phid: mstform.getItem("phid_pc").getValue() },
                function (res) {
                    const datas = JSON.parse(res.data)[0].extendObjects;
                    console.log(`获取项目信息`, datas);
                    //帮助字段赋值
                    $NG.updateState((updater) => {
                        updater.data.p_form_fact_outout_value_m.setProps({
                            u_pc_ywlx: {
                                label: datas.ywlx_name,
                                value: datas.user_ywlx
                            }
                        });
                        setTimeout(() => {
                            hideBtn()
                        }, 300)
                    });
                }
            );
        }
    }
    useClick(async function ({ args }) {
        // 获取表单中 phid_pc 的值
        const phidPcValue = mstform.getItem("phid_pc").getValue();

        // 假设 grid 是你的表格组件，并且已经加载了数据
        let gridData = grid.getRows(); // 获取 grid 中的所有行数据

        // 从 grid 数据中提取 u_shsj_name 字段的值
        let existingItems = gridData.map(row => row.u_shsj_name); // 提取所有已有的 u_shsj_name

        // 构建过滤条件字符串，假设使用 SQL IN 操作符进行过滤
        let filterCondition = existingItems.length > 0
            ? `m.phid_pc = '${phidPcValue}' AND d.u_equipment_item NOT IN ('${existingItems.join("','")}')`
            : `m.phid_pc = '${phidPcValue}'`;

        // 打开帮助选择器并应用过滤条件
        $NG.external.openNGHelp({
            type: "NGMultipleHelp",
            helpId: "cz_shsjqd",
            valueField: "u_equipment_item",
            labelField: "u_equipment_list_name",
            clientSqlFilter: filterCondition // 应用过滤条件
        }).then((data) => {
            console.log(data);

            var gridArr = []; // 初始化 gridArr 数组
            for (var i = 0; i < data.length; i++) {
                // 列出需要赋值的表体字段
                var gridObj = {
                    u_shsj_no: '',
                    u_shsj_name: '',
                    u_detailed_qty: '',
                    u_model: '',
                    u_tech_params: '',
                    u_cnt_qty: '',
                    u_unit: '',
                    prc: '',
                    taxrate: '',
                    u_ly: '',
                    u_srlx: '',
                    u_nfbsl: '',

                };
                // 对表体字段进行赋值, 可以取数据库中的值进行赋值
                gridObj.u_srlx = data[i].origin.u_revenue_type;
                gridObj.u_srlx_EXName = data[i].origin.c_name;
                gridObj.u_shsj_no = data[i].origin.u_equipment_list_no;
                gridObj.u_shsj_name = data[i].origin.u_equipment_item;
                gridObj.u_shsj_name_EXName = data[i].origin.u_equipment_list_name;
                gridObj.u_detailed_qty = data[i].origin.u_u_total_shsj;
                gridObj.u_model = data[i].origin.u_spec;
                gridObj.u_tech_params = data[i].origin.u_tech_params;
                gridObj.u_cnt_qty = data[i].origin.u_cnt_qty;
                gridObj.u_unit = data[i].origin.u_msunit;
                gridObj.u_unit_EXName = data[i].origin.msname;
                gridObj.prc = data[i].origin.u_cnt_prc;
                gridObj.taxrate = data[i].origin.u_cnt_item_tax_rate;
                gridObj.u_nfbsl = data[i].origin.qdsl;
                gridObj.u_kg_qty = data[i].origin.kglj_qty;
                gridObj.u_kg_amt = data[i].origin.kgljje;
                gridObj.u_year_amt = data[i].origin.nlje;
                gridObj.u_year_qty = data[i].origin.nl_qty;

                gridObj.u_ly = '深化设计清单手工选择';

                // 关键步骤：将 gridObj 添加到 gridArr 数组中
                gridArr.push(gridObj);
            }
            console.log(gridArr); // 确保这里打印出来的 gridArr 不是空的
            grid.addRows(gridArr); // 将数据添加到表格组件中
        });
    }, "czadd");

    useClick(async function ({ args }) {
        // 获取表单中 phid_pc 的值
        const phidPcValue = mstform.getItem("phid_pc").getValue();

        // 假设 grid 是你的表格组件，并且已经加载了数据
        let gridData = grid.getRows(); // 获取 grid 中的所有行数据

        // 从 grid 数据中提取 u_shsj_name 字段的值
        let existingItems = gridData.map(row => row.u_shsj_name); // 提取所有已有的 u_shsj_name

        // 构建过滤条件字符串，假设使用 SQL IN 操作符进行过滤
        let filterCondition = existingItems.length > 0
            ? `m.phid_pc = '${phidPcValue}' AND d.phid NOT IN ('${existingItems.join("','")}')`
            : `m.phid_pc = '${phidPcValue}'`;

        // 打开帮助选择器并应用过滤条件
        $NG.external.openNGHelp({
            type: "NGMultipleHelp",
            helpId: "cz_sbqd",
            valueField: "phid",
            labelField: "u_equipment_list_name",
            clientSqlFilter: filterCondition // 应用过滤条件
        }).then((data) => {
            console.log(data);

            var gridArr = []; // 初始化 gridArr 数组
            for (var i = 0; i < data.length; i++) {
                // 列出需要赋值的表体字段
                var gridObj = {
                    u_shsj_no: '',
                    u_shsj_name: '',
                    u_detailed_qty: '',
                    u_model: '',
                    u_tech_params: '',
                    u_cnt_qty: '',
                    u_unit: '',
                    prc: '',
                    taxrate: '',
                    u_ly: '',
                    u_srlx: '',
                    u_nfbsl: '',

                };
                // 对表体字段进行赋值, 可以取数据库中的值进行赋值
                gridObj.u_srlx = data[i].origin.u_revenue_type;
                gridObj.u_srlx_EXName = data[i].origin.c_name;
                gridObj.u_shsj_no = data[i].origin.u_equipment_list_no;
                gridObj.u_shsj_name = data[i].origin.u_equipment_item;
                gridObj.u_shsj_name_EXName = data[i].origin.u_equipment_list_name;
                gridObj.u_detailed_qty = data[i].origin.u_qty;
                gridObj.u_model = data[i].origin.u_cnt_d_spec;
                gridObj.u_tech_params = data[i].origin.u_desc;
                gridObj.u_cnt_qty = data[i].origin.u_qty;
                gridObj.u_unit = data[i].origin.u_unit;
                gridObj.u_unit_EXName = data[i].origin.msname;
                gridObj.prc = data[i].origin.u_cnt_prc;
                gridObj.taxrate = data[i].origin.u_cnt_d_taxrate;
                gridObj.u_nfbsl = data[i].origin.qdsl;
                gridObj.u_kg_qty = data[i].origin.kglj_qty;
                gridObj.u_kg_amt = data[i].origin.kgljje;
                gridObj.u_year_amt = data[i].origin.nlje;
                gridObj.u_year_qty = data[i].origin.nl_qty;

                gridObj.u_ly = '设备清单手工选择';

                // 关键步骤：将 gridObj 添加到 gridArr 数组中
                gridArr.push(gridObj);
            }
            console.log(gridArr); // 确保这里打印出来的 gridArr 不是空的
            grid.addRows(gridArr); // 将数据添加到表格组件中
        });
    }, "czsbqd");


    //项目名称变化时自动带入产品线、事业部等
    useValuesChange(({ args }) => {
        console.log(args[0]);
        //const phid_pc = args[0].pc.PhId;
        const pc = args[0].phid_pc.value;
        //从项目取值
        if (pc) {
            console.log(pc);
            Czqd(pc)

        }
        // setTimeout(()=>{
        //     hideBtn()
        // },300)
        PCFilter();
        getPtInfoByPhid()
    }, "p_form_fact_outout_value_m.phid_pc");

    useValuesChange(({ args }) => {
        hideBtn()
    }, "p_form_fact_outout_value_m.u_pc_ywlx");


    useDataIndexChange(({ args }) => {
        const record = args[0];
        console.log(record)
        if (record.u_con_qty > record.u_detailed_qty) {
            $NG.alert('完成数量不能大于深化设计数量');
            record.u_con_qty = 0
        }
        else if ((record.u_kg_qty + record.u_con_qty) > record.u_detailed_qty) {
            $NG.alert('累计完成数量不能大于深化设计数量,剩余数量为', parseFloat(record.u_detailed_qty - record.u_kg_qty));

            record.u_con_qty = 0
        }
        else {
            record.u_con_sp = record.u_con_qty
            record.u_con_amt = record.prc * record.u_con_qty / record.u_nfbsl * record.u_cnt_qty * (1 + record.taxrate)
            record.u_con_zb = record.u_con_sp / record.u_con_qty
            record.u_con_spcz = record.u_con_qty * record.prc / record.u_nfbsl * record.u_cnt_qty * (1 + record.taxrate)
            record.u_year_qty_hbc = (record.u_year_qty ?? 0) + record.u_con_qty
            record.u_year_amt_hbc = (record.u_year_amt ?? 0) + record.u_con_qty * record.prc * (1 + record.taxrate) / record.u_nfbsl * record.u_cnt_qty
            record.u_kg_qty_hbc = (record.u_kg_qty ?? 0) + record.u_con_qty
            record.u_kg_amt_hbc = (record.u_kg_amt ?? 0) + record.u_con_qty * record.prc * (1 + record.taxrate) / record.u_nfbsl * record.u_cnt_qty

        }

        grid.updateRow(args[0]);
    }, "u_con_qty");


    useDataIndexChange(({ args }) => {
        const record = args[0];
        console.log(record)

        if (record.u_con_sp > record.u_con_qty) {
            $NG.alert('审批数量不能大于完成数量');
            record.u_con_sp = record.u_con_qty
        }
        else {

            record.u_con_zb = record.u_con_sp / record.u_con_qty
            record.u_con_spcz = record.prc * (1 + record.taxrate) * record.u_con_sp / record.u_nfbsl * record.u_cnt_qty

            record.u_year_qty_hbc = (record.u_year_qty ?? 0) + record.u_con_sp
            record.u_year_amt_hbc = (record.u_year_amt ?? 0) + (record.prc * (1 + record.taxrate) * record.u_con_sp / record.u_nfbsl * record.u_cnt_qty)
            record.u_kg_qty_hbc = (record.u_kg_qty ?? 0) + record.u_con_sp
            record.u_kg_amt_hbc = (record.u_kg_amt ?? 0) + (record.prc * (1 + record.taxrate) * record.u_con_sp / record.u_nfbsl * record.u_cnt_qty)

        }
        grid.updateRow(args[0]);
    }, "u_con_sp");


    useUpdateRows(({ args, table }) => {
        // const u_jzbcby_amt = mstform.getItem("u_jzbcby_amt").getValue(); //获取值
        // const u_jzbcby_amt_vat = mstform.getItem("u_jzbcby_amt_vat").getValue(); //获取值
        // const amt = mstform.getItem("amt").getValue(); //获取值
        var sumAmt = 0;
        const rows = args[0];
        rows.forEach((items) => {
            if (items.u_con_spcz) {
                sumAmt += parseFloat(items.u_con_spcz);  //明细
            }
            //汇总赋值到表头字段
            $NG.updateState((updater) => {
                updater.data.p_form_fact_outout_value_m.setProps({
                    u_amt_sum: sumAmt,
                    u_kc_hbc: sumAmt + mstform.getItem("u_total_sum").getValue(),
                    u_nl_hbc: sumAmt + mstform.getItem("u_kg_sum").getValue(),
                });
            });

        });
        grid.updateRow(rows);
    }, 'p_form_fact_outout_value_d');

    function hideBtn() {
        const gridt = $NG.getCmpApi("toolbar_p_form_fact_outout_value_d")
        let lock = true
        if (mstform.getItem("u_pc_ywlx").getValue() == '8570000000000350') {
            lock = false
        } else {
            lock = true
        }
        if (!mstform.getItem("u_pc_ywlx").getValue()) {
            gridt.hideButton("czadd")
            gridt.hideButton("czsbqd")
            return
        }
        if (!lock) {
            gridt.hideButton("czadd")
            $NG.getCmpApi('toolbar_p_form_fact_outout_value_d').insert({
                id: "czsbqd",
                text: "引用设备清单内容",
                iconCls: "icon-New"
            });
        } else {
            gridt.hideButton("czsbqd")
            $NG.getCmpApi('toolbar_p_form_fact_outout_value_d').insert({
                id: "czadd",
                text: "引用深化设计清单内容",
                iconCls: "icon-New"
            });
        }
    }
});


//合同根据项目ID过滤
function PCFilter() {
    $NG.updateUI((updater, state) => {
        console.log('过滤参数检查', updater);
        updater.fieldSetForm.p_form_fact_outout_value_m.u_cnt_name.setProps({
            onBeforeOpen: async () => {
                var phid_pc = $NG.getCmpApi('p_form_fact_outout_value_m').getItem('phid_pc').getValue();
                if (!phid_pc) {
                    $NG.alert("请先选择项目");
                    return false;
                } else {
                    return true;
                }
            },
            ...(!!$NG.getCmpApi('p_form_fact_outout_value_m').getItem('phid_pc').getValue() && {
                clientSqlFilter: {
                    phid_pc: $NG.getCmpApi('p_form_fact_outout_value_m').getItem('phid_pc').getValue()
                }
            }),
        });
    });
}



function Czqd(pcvalue) {

    const mstform = $NG.getCmpApi("p_form_fact_outout_value_m");
    const grid = $NG.getCmpApi("p_form_fact_outout_value_d");

    var pcname = mstform.getItem("phid_pc").getRawValue().label
    var cycle = mstform.getItem("phid_cycle").getRawValue().label
    $NG.updateState((updater) => {
        updater.data.p_form_fact_outout_value_m.setProps({
            bill_name: pcname + cycle + "产值填报",

        });
    });


    grid.clearRows();



    $NG.execServer("GetCzLjInfo", { pc: pcvalue }, function (res) {
        if (res.count == 0) return;
        const data = JSON.parse(res.data);
        const cz_klje = data[0].extendObjects.cz_klje;
        const cz_nlje = data[0].extendObjects.cz_nlje;
        console.log('执行到这儿了啊啊啊啊啊啊')
        console.log(res.count)
        //项目类型
        if (res.count > 0) {
            $NG.updateState((updater) => {
                updater.data.p_form_fact_outout_value_m.setProps({
                    u_total_sum: cz_nlje,
                    u_kg_sum: cz_klje,

                });
            });
        }
        else {
            $NG.updateState((updater) => {
                updater.data.p_form_fact_outout_value_m.setProps({
                    u_total_sum: 0,
                    u_kg_sum: 0,


                });
            });

        }
    });


    $NG.execServer("CzGetCntInfo", { pc: pcvalue }, function (res) {
        if (res.count == 0) return;
        const data = JSON.parse(res.data);
        const cntid = data[0].extendObjects.cntid;
        const cntname = data[0].extendObjects.cntname;

        //项目类型
        $NG.updateState((updater) => {
            updater.data.p_form_fact_outout_value_m.setProps({
                u_cnt_name: {
                    //帮助需要赋两个值value、label
                    value: cntid,
                    label: cntname,
                },

            });
        });
    });


    $NG.execServer('GetCzQd', { pc: pcvalue }, function (res) {
        if (res.count == 0) return;
        const data = JSON.parse(res.data);

        var gridArr = []; // 定义表体数组
        var gridCount = res.count; // 增加的行数, 可根据从数据库中取出的数据总数增行
        for (var i = 0; i < gridCount; i++) {
            // 列出需要赋值的表体字段
            var gridObj = {
                u_shsj_no: '',
                u_shsj_name: '',
                u_detailed_qty: '',
                u_model: '',
                u_tech_params: '',
                u_cnt_qty: '',
                u_unit: '',
                prc: '',
                u_con_qty: '',
                u_con_amt: '',
                u_con_sp: '',
                u_con_spcz: '',
                // u_nexplan_qty: '',
                // u_nexplan_amt:'',
                // u_nxplan_qtyzb: '',
                u_year_qty: '',
                u_year_amt: '',
                u_kg_qty: '',
                u_kg_amt: '',
                u_srlx: '',
                taxrate: '',
                u_ly: '',
                u_nfbsl: '',
                u_year_qty_hbc: '',
                u_year_amt_hbc: '',
                u_kg_qty_hbc: '',
                u_kg_amt_hbc: '',
            };
            // 对表体字段进行赋值, 可以取数据库中的值进行赋值
            // 确保这些字段为空时赋值为 0
            const rest_qty = data[i].extendObjects.rest_qty;
            const cz_klje = data[i].extendObjects.cz_klje ?? 0;
            const czsl_year_total = data[i].extendObjects.czsl_year_total ?? 0;
            const czje_year_total = data[i].extendObjects.czje_year_total ?? 0;
            const cz_klsl = data[i].extendObjects.cz_klsl ?? 0;

            // 其他字段赋值
            gridObj.u_shsj_no = data[i].extendObjects.sbqd_no || "";

            gridObj.u_srlx = data[i].extendObjects.u_revenue_type || "";
            gridObj.u_srlx_EXName = data[i].extendObjects.srlx_name || "";
            gridObj.u_shsj_name = data[i].extendObjects.sbqdid || "";
            gridObj.u_shsj_name_EXName = data[i].extendObjects.sbqd_name || "";
            gridObj.u_detailed_qty = data[i].extendObjects.sh_qty ?? 0;
            gridObj.u_model = data[i].extendObjects.spec || "";
            gridObj.u_tech_params = data[i].extendObjects.jscs || "";
            gridObj.u_cnt_qty = data[i].extendObjects.ht_qty ?? 0;
            gridObj.u_unit = data[i].extendObjects.msunit || "";
            gridObj.u_unit_EXName = data[i].extendObjects.msname || "";
            gridObj.prc = data[i].extendObjects.prc ?? 0;
            gridObj.u_nfbsl = data[i].extendObjects.qdsl;
            // 计算字段
            gridObj.u_con_qty = rest_qty;
            gridObj.u_con_amt = data[i].extendObjects.prc * (1 + data[i].extendObjects.taxrate) * (rest_qty / data[i].extendObjects.qdsl) * data[i].extendObjects.ht_qty;
            gridObj.u_con_sp = rest_qty;
            gridObj.taxrate = data[i].extendObjects.taxrate || 0;
            gridObj.u_con_spcz = data[i].extendObjects.prc * (1 + data[i].extendObjects.taxrate) * (rest_qty / data[i].extendObjects.qdsl) * data[i].extendObjects.ht_qty;
            gridObj.u_con_zb = rest_qty !== 0 ? rest_qty / rest_qty : 0; // 避免除零错误

            gridObj.u_year_qty = czsl_year_total;
            gridObj.u_year_amt = czje_year_total;
            gridObj.u_kg_qty = cz_klsl;
            gridObj.u_kg_amt = cz_klje;
            gridObj.u_ly = data[i].extendObjects.ly || "";

            gridObj.u_year_qty_hbc = czsl_year_total + rest_qty;
            gridObj.u_year_amt_hbc = czje_year_total + data[i].extendObjects.prc * (1 + data[i].extendObjects.taxrate) * (rest_qty / data[i].extendObjects.qdsl) * data[i].extendObjects.ht_qty
            gridObj.u_kg_qty_hbc = cz_klsl + rest_qty;
            gridObj.u_kg_amt_hbc = cz_klje + data[i].extendObjects.prc * (1 + data[i].extendObjects.taxrate) * (rest_qty / data[i].extendObjects.qdsl) * data[i].extendObjects.ht_qty;
            gridArr.push(gridObj);
        }

        // 清空表格内容（放在循环外部）
        grid.clearRows();

        // 调用新增表体行数据的函数
        grid.addRows(gridArr);

        // 更新RichHelp字段（如果需要）
        // 这里假设有一个方法可以刷新或重新渲染表格，以确保RichHelp字段正确显示
        grid.refreshView(); // 或者使用grid.refreshData();
    });

}
function getTjzq(dt) {

    $NG.execServer("GetTjzq", { dt: dt }, function (res) {
        if (res.count == 0) return;
        const data = JSON.parse(res.data);
        const phid = data[0].extendObjects.phid;
        const bill_name = data[0].extendObjects.bill_name;
        //项目类型
        $NG.updateState((updater) => {
            updater.data.p_form_fact_outout_value_m.setProps({
                phid_cycle: {
                    //帮助需要赋两个值value、label
                    value: phid,
                    label: bill_name,
                },

            });
        });
    });
}

// 弹窗数据
const tableData = {
    columns: [
        { name: "二级分类", width: "20%" },
        { name: "分值", width: "10%" },
        { name: "标准调整", width: "50%" },
        { name: "评分", width: "20%" }  // 新增评分列
    ],
    rows: [
        {
            '二级分类': '交付及时性',
            '分值': "<span class='pj-hisense-badge pj-badge-green'>100</span>",
            '标准调整': `<ul>
            <li class="pj-li">1、支撑项目紧急需求，优于项目进度约定交付时间，进行交付，100分。</li>
            <li class="pj-li">2、按照项目进度约定交付时间，进行交付。80分。</li>
            <li class="pj-li">3、未按照品类/合同约定交付时间，未造成影响，60分。</li>
            <li class="pj-li">4、未按照品类/合同约定交付时间，对我司项目造成一定影响，例施工进度造成实施影响，30分。</li>
            <li class="pj-li">5、未按照品类/合同约定交付时间，对我司项目造成严重影响，例客户投诉函件、罚款单等，0分。</li>
            </ul>`
        },
        {
            '二级分类': '资源投入',
            '分值': "<span class='pj-hisense-badge pj-badge-green'>100</span>",
            '标准调整': `<ul>
            <li class="pj-li">1、投入的人员数量及专业人员资质符合要求，能支持项目正常开展，并对特殊需求能及时快速响应，100分。</li>
            <li class="pj-li">2、投入的人员数量及专业人员资质符合要求，能支持项目正常开展，80分。</li>
            <li class="pj-li">3、投入的人员数量及专业人员资质低于要求，能支持项目正常开展，60分。</li>
            <li class="pj-li">4、投入的人员数量及专业人员资质符合要求，不能支持项目正常开展，30分。</li>
            <li class="pj-li">5、投入的人员数量及专业人员资质低于要求，不能支持项目正常开展，0分。</li>
            </ul>`
        },
        {
            '二级分类': '交付质量',
            '分值': "<span class='pj-hisense-badge pj-badge-green'>100</span>",
            '标准调整': `<ul>
            <li class="pj-li">1、未出现质量问题，且配合海信完成业主特定需求。100分。</li>
            <li class="pj-li">2、未出现质量问题。80分。</li>
            <li class="pj-li">3、出现质量问题，未造成影响，60分。</li>
            <li class="pj-li">4、出现质量问题，对我司项目造成一定影响，例施工进度、客户满意度（未发函、罚款）造成实施影响，30分。</li>
            <li class="pj-li">5、出现质量问题，对我司项目造成严重影响，例客户投诉函件、罚款单、安全问题等，0分。</li>
            </ul>`
        },
        {
            '二级分类': '服务响应',
            '分值': "<span class='pj-hisense-badge pj-badge-green'>100</span>",
            '标准调整': `<ul>
            <li class="pj-li">1、按照合同约定时间服务响应及时，且配合海信完成业主特定需求。100分。</li>
            <li class="pj-li">2、按照合同约定时间服务响应及时。80分。</li>
            <li class="pj-li">3、按照合同约定时间服务响应不及时，未造成影响，60分。</li>
            <li class="pj-li">4、按照合同约定时间服务响应不及时，对我司项目造成一定影响，例实施服务及时性、客户满意度（未发函、罚款）造成实施服务影响，30分。</li>
            <li class="pj-li">5、按照合同约定时间服务响应不及时，对我司项目造成严重影响，例客户投诉函件、罚款单、安全问题等，0分。</li>
            </ul>`
        }
    ]
}
initPjWindows(tableData, "二级分类")
// 评分弹框，代码过长，软件可能会停止解析语法错误无需担心
function initPjWindows(d, k) { const s = `<style>:root{--pj-hisense-green:#00aaa6;--pj-hisense-light:#e8f5e9;--pj-hisense-dark:#00aaa6;}.pj-body{display:none;background:rgba(0,0,0,0.34);position:fixed;z-index:999;overflow:auto;font-family:"Helvetica Neue",Arial,sans-serif;padding:30px;width:100vw;height:100vh;}@keyframes bigBox{0%{width:0;transform:scaleY(0)}100%{width:70vw;transform:scaleY(1)}}.pj-li{list-style:none;padding:2px;}.pj-hisense-container{animation:bigBox 0.2s linear;width:70vw;margin:0 auto;padding:30px;background-color:#fff;border-radius:15px;}.pj-hisense-table{width:100%;border-collapse:separate;border-spacing:0;background:white;border-radius:12px;overflow:hidden;box-shadow:0 6px 20px rgba(0,168,98,0.1);}.pj-hisense-table thead tr{background:linear-gradient(135deg,var(--pj-hisense-green),var(--pj-hisense-dark));color:white;text-align:left;font-size:12px;}.pj-hisense-table th{padding:18px 15px;font-weight:600;letter-spacing:0.5px;position:relative;}.pj-hisense-table th:not(:last-child)::after{content:"";position:absolute;right:0;top:20%;height:60%;width:1px;background:rgba(255,255,255,0.3);}.pj-hisense-table td{padding:15px;border-bottom:1px solid #e0ece5;color:#333;font-size:10px;}.pj-hisense-table tbody tr:nth-child(even){background-color:var(--pj-hisense-light);}.pj-hisense-table tbody tr:last-child td{border-bottom:none;}.pj-hisense-table tbody tr:hover{background-color:rgba(0,168,98,0.08);transition:all 0.3s ease;}.pj-hisense-badge{display:inline-block;padding:4px 12px;border-radius:16px;font-size:12px;font-weight:600;}.pj-badge-green{background-color:rgba(0,168,98,0.15);color:var(--pj-hisense-dark);}.pj-badge-blue{background-color:#e3f2fd;color:#1976d2;}.pj-hisense-btn{padding:10px 20px;background:var(--pj-hisense-green);color:white;border:none;border-radius:6px;cursor:pointer;font-weight:500;transition:all 0.2s;margin-left:10px;}.pj-hisense-btn:hover{background:var(--pj-hisense-dark);transform:translateY(-1px);box-shadow:0 2px 8px rgba(0,168,98,0.3);}.pj-status-active{color:var(--pj-hisense-green);font-weight:600;position:relative;padding-left:20px;}.pj-status-active::before{content:"";position:absolute;left:0;top:50%;transform:translateY(-50%);width:12px;height:12px;background:var(--pj-hisense-green);border-radius:50%;}.pj-status-inactive{color:#f44336;font-weight:600;}.pj-table-caption{font-size:24px;color:var(--pj-hisense-dark);margin-bottom:20px;font-weight:600;display:flex;align-items:center;}.pj-table-caption::before{content:"";display:inline-block;width:8px;height:24px;background:var(--pj-hisense-green);margin-right:12px;border-radius:4px;}.pj-input-group{margin-bottom:20px;display:flex;}.pj-hisense-input{padding:10px 15px;border:1px solid #ddd;border-radius:6px;flex-grow:1;font-size:16px;transition:border 0.3s;}.pj-hisense-input:focus{outline:none;border-color:var(--pj-hisense-green);box-shadow:0 0 0 2px rgba(0,168,98,0.2);}.pj-table-footer{margin-top:20px;display:flex;justify-content:flex-end;}.pj-row-input{padding:8px 12px;border:1px solid #ddd;border-radius:4px;margin-right:10px;width:100px;}.pj-score-input{padding:8px;border:1px solid #ddd;border-radius:4px;width:80px;}</style>`, m = `<div class="pj-body"><div class="pj-hisense-container"><div class="pj-table-caption">评价标准</div><div id="pj-tableContainer"></div><div class="pj-table-footer"><button id="pj-getAllScoresBtn" class="pj-hisense-btn">提交</button></div></div></div>`; document.body.insertAdjacentHTML("afterbegin", m), document.head.insertAdjacentHTML("beforeend", s); const h = () => document.querySelector(".pj-body").style.display = "none", w = () => document.querySelector(".pj-body").style.display = "block"; document.querySelector(".pj-body").addEventListener("click", e => { if (e.target === e.currentTarget) h() }); function g(data) { let t = `<table class="pj-hisense-table"><thead><tr>`; data.columns.forEach(c => t += `<th style="width:${c.width}">${c.name}</th>`), t += `</tr></thead><tbody>`, data.rows.forEach((r, i) => { t += `<tr data-row-index="${i}">`, data.columns.forEach(c => { if (c.name === "评分") t += `<td><input type="text" class="pj-score-input" data-row-id="${r[k]}" placeholder="输入评分"></td>`; else { const v = r[c.name] || ""; t += `<td>${v}</td>` } }), t += `</tr>` }), t += `</tbody></table>`, document.getElementById("pj-tableContainer").innerHTML = t } function a() { return [...document.querySelectorAll(".pj-score-input")].map(e => ({ productId: e.getAttribute("data-row-id"), score: e.value })) } g(d), document.getElementById("pj-getAllScoresBtn").addEventListener("click", e => { const s = a(); try { window.$PJ.submit(s) } catch (e) { alert("提交函数未被重写，window.$PJ.submit") } console.log("所有评分数据：", s) }), window.$PJ = window.$PJ || {}, Object.assign(window.$PJ, { pjGenerateTable: g, onShowPj: w, onHiddenPj: h }) } 